﻿@using DLULearningNetworkModel
@model DLULearningNetworkModel.SeminarSchedule
@{
    bool isOwner = false;
    List<ScheduleTime> scheduleTimes = new List<ScheduleTime>();
    if (Model != null)
    {
        scheduleTimes = ScheduleTime.SelectBySeminarScheduleID(Model.SeminarScheduleID_u).OrderBy(st => st.Start_t).ToList();
    }
    
    if(Course.Single(DLULearningNetwork.Controllers.FrontEndBaseController.LoginUser.AccountID_u, Model.CourseID_u) != null)
    {
        isOwner = true;
    }
}
<script type="text/javascript" src="../../Scripts/Custom/jsScheduleTime.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        ScheduleTimes.init();        
    });
</script>
@if (isOwner)
{
<div>
    @if (ViewBag.CreateScheduleTimeMessage != null)
    { 
        <div class="box_error" style="display:block;">@ViewBag.CreateScheduleTimeMessage</div>
        <div class="clearall"></div>
    }
    <div style="float:left; width:240px;">
        <div>
            <div style="width: 120px; font-family: Times New Roman; float: left; line-height: 22px;">
                Thời gian bắt đầu:
            </div>
            <select id="BeginHour">
                @for (int i = 0; i <= 23; i++)
                {
                    <option value="@i">@i</option>
                }
            </select>
            :
            <select id="BeginMinute">
                @for (int i = 0; i <= 60; i += 5)
                {
                    if (i == 60)
                    {
                        i = 59;
                    }
                    <option value="@i">@i</option>
                }
            </select>
        </div>
        <div class="clearall">
        </div>
        <div style="margin-top: 5px;">
            <div style="width: 120px; font-family: Times New Roman; float: left; line-height: 22px;">
                Thời gian kết thúc:
            </div>
            <select id="EndHour">
                @for (int i = 0; i <= 23; i++)
                {
                    <option value="@i">@i</option>
                }
            </select>
            :
            <select id="EndMinute">
                @for (int i = 0; i <= 60; i += 5)
                {
                    if (i == 60)
                    {
                        i = 59;
                    }
                    <option value="@i">@i</option>
                }
            </select>
        </div>
    </div>
    <div style="float:left;">
        <div style="width:60px; font-family: Times New Roman; float: left; line-height: 22px;">
                Ghi chú:
        </div>        
        <textarea id="Description" style="height:100%; width:220px; resize:none; float:left; font-size:12px;" />
        <div class="clearall"></div>
        <button class="button" id="AddScheduleTime" seminarScheduleID="@Model.SeminarScheduleID_u" style="float:right; margin-top:5px;">Thêm</button>
    </div>
</div>
<div class="clearall"></div>
}
<table class="tbl1" cellspacing="0" style="margin-top: 10px; font-family: Verdana, Tahoma, Arial;
    font-size: 14px; margin-top:5px;">
    <tr>
        <th style="width: 120px; background-color: #91c674;">
            Bắt đầu
        </th>
        <th style="width: 120px; background-color: #91c674;">
            Kết thúc
        </th>
        <th style="background-color: #91c674;">
            Ghi chú
        </th>
        <th style="width: 50px; background-color: #91c674;"></th>
    </tr>
    <tbody>
        @for (int i = 0; i < scheduleTimes.Count; i++)
        {                        
            <tr ScheduleTimeID="@scheduleTimes[i].ID_u">
                <td style="text-align:center;">
                    <span style="width:20px;">@scheduleTimes[i].Start_t.Hours.ToString()</span>
                    :
                    <span style="width:20px;">@scheduleTimes[i].Start_t.Minutes.ToString()</span>                    
                </td>
                <td style="text-align:center;">
                    <span style="width:20px;">@scheduleTimes[i].End_t.Hours.ToString()</span>
                    :
                    <span style="width:20px;">@scheduleTimes[i].End_t.Minutes.ToString()</span>                                        
                </td>
                <td>
                    <span style="width:190px;">@scheduleTimes[i].Description_s</span>                    
                </td>
                <td>
                @if (isOwner)
                {
                    <span class="delete_icon16"></span>
                }
                </td>
            </tr>
        }
    </tbody>
</table>
